package com.nb.protocol.service;


import com.nb.protocol.protocol.MessageHolder;
import com.nb.protocol.protocol.ProtocolHeader;
import io.netty.channel.Channel;
import io.netty.util.ReferenceCountUtil;


/**
 * 业务分发器.
 *
 * @author Yohann.
 */
public class Dispatcher {

    public static void dispatch(MessageHolder messageHolder) {

        switch (messageHolder.getType()) {
            // 登录
            case ProtocolHeader.POSTURE:
               new PostureService().reportData(messageHolder);
               break;
            case ProtocolHeader.VBAT:
                new VbatService().reportData(messageHolder);
                break;
            case ProtocolHeader.GPS:
                new GpsService().reportData(messageHolder);
                break;
            case ProtocolHeader.POSTURE_VBAT:
                new PostureVbatService().reportData(messageHolder);
                break;

            // 请求错误
            default:
                //response(messageHolder.getChannel(), messageHolder.getSign());
                break;
        }

        // 释放buffer
        //ReferenceCountUtil.release(messageHolder);
    }


}
